﻿#ifndef MLABEL_H
#define MLABEL_H

#include <QLabel>

enum enumPlay_Effect {
    Effect_Static = 0x00,
    Effect_MoveLeft = 0x01,
    Effect_ScrollUp = 0x02,
};

const int g_nTimerInterval[10] = {1, 2, 3, 4, 6, 8, 10, 25, 50, 100};

class MLabel : public QLabel
{
    Q_OBJECT
public:
    MLabel(QWidget* parent = NULL);

    void setPlayEffect(enumPlay_Effect nEffect);
    void setPlaySpeed(int nSpeed);
    int  getPlayTimes(); //播放一次时间, 毫秒

    bool createAvi();

public slots:
    void setText(const QString&);
    void setImage(const QString& strImgFile);

protected:
    virtual void paintEvent(QPaintEvent* e);
    virtual void timerEvent(QTimerEvent* e);
    virtual void resizeEvent(QResizeEvent* e);

    void upateLabelRollingState();

private:
    int m_nRoll_Left;
    int m_nRoll_Top;

    int timerId;
    int fontSize;

    bool m_bImgOrText;
    enumPlay_Effect m_nEffect;
    bool m_bLoop;

    QImage        *m_pImage;
    QRect         m_srcRect;
    QRect         m_dstRect;

    QFont m_ft;

    int m_nImgScale;
    int m_nActImgWidth;
    int m_nActImgHeight;

    int m_nSpeed; //定时器间隔时间
};

#endif // MLABEL_H
